<template>
    <el-main>
        <el-main class="ep-body">
            <epl-top-bar :datas="{formData:form}" showPerson psTagType="PERSON_PENSION_QUERY" personType="PERSON_ALL_EXACT">
            </epl-top-bar>
            <epl-userMessage dataType="person" idCount = "1">
            </epl-userMessage>
            <el-card class="ep-card">
                <el-form :model="form" :rules="rules">
                    <ep-title>待办基本信息</ep-title>
                    <el-row :gutter="10">
                        <ep-select colspan="8" placeholder="请选择离退休类型" label="离退休类型" name="aic161" :property="form.aic161" codetype="AIC161"
                                   p="R"  :datas="{formData:form}"></ep-select>
                        <ep-date colspan="8" label="离退休时间" name="aic162"  :property="form.aic162"
                                 placeholder="请选择离退休时间" p="R" format="yyyyMM" :datas="{formData:form}"></ep-date>
                        <ep-date colspan="8" label="待遇享受开始年月" name="aic160"  :property="form.aic160"
                                 placeholder="请选择待遇享受开始年月" p="R" format="yyyyMM" :datas="{formData:form}"></ep-date>
                    </el-row>
                    <el-row type="flex" justify="center">
                        <ep-saveButton id=""  type="primary" top="20" bottom="20"
                                       :datas="{formData: form,panel:panel}"></ep-saveButton>
                    </el-row>
                </el-form>
            </el-card>
        </el-main>
    </el-main>
</template>
<script type="es6">
    export default {
        data() {
            return {
                form:{
                    aic161: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aic162: {
                        value: '',
                        p: 'R'
                    },
                    aic160: {
                        value: '',
                        p: 'R'
                    },

                },
                panel: {},

                rules:{
                    aic161: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    aic162: [
                        {required: true, message: '必填项，不能为空'}

                    ],
                    aic160: [
                        {required: true, message: '必填项，不能为空'}

                    ],

                },
                codeTypes:{
                    AIC161:[],

                },
                codeTypeFilters:{

                },
                pager: {
                    page: 1,
                    size: 10
                },
                total: 0,
            }
        },
        computed: {
            functionId() {
                if (this.$store.getters.init.path !== this.$route.path) return;
                if (this.$store.getters.init.mdParam === null || this.$store.getters.init.mdParam === undefined) return;
                if (this.$store.getters.init.mdParam.functionid === undefined) return;
                return this.$store.getters.init.mdParam.functionid;
            },
            backFun() {
                return this.$store.getters.backFun;
            },
            init_formData() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.form;
            },
            doInitformData: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.formData;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },
            init_panel() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.panel;
            },
            doInitpanel: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.panel;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },

        },
        created() {
            let param = {
                path: this.$route.path,
                codeTypes:this.codeTypes,
                codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                form:this.form,
                panel:this.panel

            };
            this.$store.dispatch('SET_INIT', param);
        },
        watch: {
            init_formData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            doInitformData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            init_panel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },
            doInitpanel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },

            backFun: {
                handler(value) {
                    if (value === null) return;
                    this.customBackFun();
                    let backFun = [];
                    backFun = value.split(',');
                    if (backFun.indexOf('rDoInit') >= 0) {
                        let codeTypes = {
                            AIC161:[],

                        };
                        let form = {
                            aic161: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aic162: {
                                value: '',
                                p: 'R'
                            },
                            aic160: {
                                value: '',
                                p: 'R'
                            },

                        };
                        let panel= {};

                        let param = {
                            path: this.$route.path,
                            codeTypes:codeTypes,
                            codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                            form:form,
                            panel:panel

                        };
                        this.$store.dispatch('SET_INIT', param);
                    }
                }
            }
        },
        methods: {
            getformData(value) {
                this.form = value;
            },
            getpanel(value) {
                this.panel = value;
            },

            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            handleEdit(id) {
                this.dialogFormVisible = true;
            },

            customBackFun(){//自定义方法体
            },
        },
    }
</script>
